﻿using Huasky.MyWrod.Common.Util;
using Mapster;

namespace Huasky.MyWrod.Web.Core.Extensions;

/// <summary>
/// 注入对象映射
/// </summary>
public static class MapperEx
{
    /// <summary>
    /// 添加对象的映射关系
    /// </summary>
    /// <param name="services"></param>
    public static void AddHuaskyMapper(this IServiceCollection services)
    {
        services.AddMapster();
        // 读取所有的映射关系，加入映射表
        var mappers = DIHelper.CreateAll<IHuaskyMapper>();
        foreach (var mapper in mappers)
        {
            mapper.Register();
        }
    }
}
